<template>
	<yd-layout id='courseStage' class=''>
		<div class="header">
			<img :src="dataObj.title_img" class="header_img" alt="" />
			<div class="header_title">
				<div class="title">{{dataObj.title}}</div>
				<div class="label">
					<div v-if="dataObj.is_member==1" class="vip">会员课程</div>
					<div class="num">共{{dataObj.video_count}}节</div>
				</div>
			</div>
		</div>
		<div class="content">
			<ul class="nav">
				<li @click="navNum=1" style="color: #333333;" :class="navNum==1?'nav_active':''">
					<div>课程目录</div>
					<!--<span></span>-->
				</li>
				<li  v-if="false" @click="navNum=2" :class="navNum==2?'nav_active':''">
					<div>课程简介</div>
					<span></span>
				</li>
			</ul>
			<div v-show="navNum==1" class="course_list_f">
				<template  v-if="courseList.length>0">
					<div @click="goCourseVideoDetailVip(item)" class="course_list" v-for="item in courseList">
						<div class="course_list_top">
							<img class="course_list_img" src="../../assets/play_icon.png" alt="" />
							<div class="course_list_title">{{item.title}}</div>
						</div>
						<div v-if="item.is_buy==1" class="course_list_money" style="color: #999999;">已购买</div>
						<div v-else-if='item.price==0' class="course_list_money">免费</div>
						<div v-else class="course_list_money">￥{{item.price}}</div>
					</div>
				</template>
				<div v-else class="no_content">暂无课程目录</div>
			</div>
			
			<div  v-show="navNum==2">
				<div v-if="dataObj.summary" v-html="dataObj.summary" class="c_v_html"></div>
				<div class="no_content" v-else>暂无简介</div>
			</div>
		</div>
	</yd-layout>
</template>

<script>
	export default{
		components:{
			
		},
		data(){
			return {
				navNum:1,
				courseList:[],
				dataObj:{},
				mineObj:{},
			}
		},
		created() {
		},
		watch: {
			
		},
		computed: {
			
		},
		async mounted(){
			document.title='课程目录';
			await this.getMine();
			this.getCourseDetail()
		},
		methods:{
			getMine(){
				return new Promise((resolve,reject) => {
					this.$root.ajax({
						closeAllLoading: true,
						name: 'my',
						params: {
	
						}
					}).then((d) => {
						this.mineObj=d.data
						resolve()
					})
				})
			},
			async goCourseVideoDetailVip(item){
				var	d = await this.$root.courseAuthFlg({
						name:'courseVideoDetailVip',
						query:{
							id:item.id
						},
						id:this.$route.query.id,
						vipFlg:this.mineObj.member_status==1?true:false,
						isBuyCouse:true, //目录不做判断，点击播放时做判断
				});
			},
			getCourseDetail(){
				this.$root.ajax({
					name: 'course',
					type:'get',
					closeAllLoading:false,
					params: {
						id:this.$route.query.id
					}
				}).then((d) => {
					for(let a =0;a<d.data.video_list.length;a++){
						d.data.video_list[a].price = this.$root.setMoneyZero(d.data.video_list[a],'price')
					}
					this.courseList = d.data.video_list 
					this.dataObj = Object.assign({},this.dataObj,d.data.course)
					
					//分享
					if(this.$root.isWeiXin()){
						//分享
						let query = '';
						if(this.$root.config.channel){
						 	query = `params=channelDY2FGoldUrlStrDY${this.$route.name}FGkeyNumDY1FGparamsKey1DYidFGparamsVal1DY${this.dataObj.id}`
						}else{
						 	query = `params=channelDY2FGoldUrlStrDY${this.$route.name}FGkeyNumDY1FGparamsKey1DYidFGparamsVal1DY${this.dataObj.id}`
						}
						this.$root.wxShare({
							d:{title:this.dataObj.title,title_img:this.dataObj.title_img},//分享对象，题目等{title:'',title-img:''}
							query: query,//参数
							desc:`${this.dataObj.share_summary}`//分享详情
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	@import './courseStage.scss';
</style>